<?php

class BuildingVoList extends SzAbstractMySqlVoList
{

    /**
     * Initialize BuildingVoList.
     *
     * @param array $list array of BuildingVo
     * @return BuildingVoList
     */
    public function __construct($list)
    {
        parent::__construct($list);

        $this->listClassName = 'BuildingVoList';
        $this->ormName = 'Building';
    }

    /**
     * 根据 itemDefId 列出所有装饰物Vo
     *
     * @param int $itemDefId
     * @throws SzException 10514
     * @return array $list;
     */
    public function getElementsByItemDefId($itemDefId)
    {
        $list = array();
        /* @var BuildingVo $building */
        foreach ($this->list as $building) {
            if (intval($building->getBuildingDefId() / 10000) != intval($itemDefId / 10000)) {
                continue; // 不符合条件
            }
            $id = $building->getDecorId();
            $list[$id] = $this->list[$id];
        }

        return $list;
    }

    /**
     * 根据 itemDefId 获得所有装饰物的数量
     *
     * @param int $itemDefId
     * @throws SzException 10514
     * @return int;
     */
    public function getElementsCountByItemDefId($itemDefId)
    {
        return count($this->getElementsByItemDefId($itemDefId));
    }
}